package com.pmcc.core.web;

import com.pmcc.core.entity.security.Menu;
import com.pmcc.core.service.MenuService;
import com.pmcc.utils.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by syk on 17/7/6.
 */
@RestController()
@RequestMapping("api/v1/menus")
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping(value = "queryList", method = RequestMethod.GET)
    @ResponseBody
    public ResultBean queryList() {
        return menuService.queryList();
    }
    /**
     * 新增菜单
     *
     * @param model
     * @return
     */
    @PostMapping("saveOrUpdate")
    public ResultBean saveOrUpdate(@RequestBody Menu model) {
        return menuService.saveOrUpdate(model);
    }

    /**
     * 删除
     *
     * @param model
     * @return
     */
    @DeleteMapping()
    @ResponseBody
    public ResultBean delete(@RequestBody Menu model) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        menuService.delete(model.getId());
        return resultBean;
    }
}
